<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        width: 500px;
        display: flex;
        margin: auto;
        flex-wrap: wrap;
      }
      .list {
        width: 24%;
        height: 100px;
        background-color: skyblue;
        margin-top: 15px;
      }

      /* 这里有4列,所以这里设置   .list:not(:nth-child(4n)) */
      /**
      如果有k列，
        .list:not(:nth-child(kn)) {
        margin-right: calc(k% / 3);
      }
      */
      .list:not(:nth-child(4n)) {
        margin-right: calc(4% / 3);
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="list"></div>
      <div class="list"></div>
      <div class="list"></div>
      <div class="list"></div>
      <div class="list"></div>
      <div class="list"></div>
      <div class="list"></div>
    </div>
  </body>
</html>
